<#assign base=request.contextPath />
<!DOCTYPE html>
<div class="row">
	<div class="col-md-12 col-sm-12 col-xs-12">
		<div class="x_panel">
			<div class="x_title">
				<h2>培训编辑 <small></small></h2>
				<div class="clearfix"></div>
			</div>
			<div class="x_content">
				<br/>
				<form id="postForm" data-parsley-validate class="form-horizontal form-label-left" method="post" action="${base}/gx/training/save">
				
		            <input type="hidden" name="addTime" value="${(obj.addTime)!.now?string['yyyy-MM-dd HH:mm:ss']}">
		            <input type="hidden" name="updateTime" value="${.now?string['yyyy-MM-dd HH:mm:ss']}">
		            <input type="hidden" name="addName" value="${(obj.addName)!admin.userName}">
		            <input type="hidden" name="updateName" value="${(obj.updateName)!admin.userName}">
		            <input type="hidden" name="isDelete" value="${((obj.isDelete)?c)!0 }">
		          
					<div class="form-group">
						<label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">培训标题 <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                        	<input type="text" id="trainingTitle" name="trainingTitle" value="${(obj.trainingTitle)!''}" class="form-control col-md-7 col-xs-12">
                        </div>
					</div>
					
						<div class="form-group">
						<label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">标题图片 <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                        	<input type="file" id="cardIcon_dropify" name="file1" class="dropify" data-default-file="${imagePath}${(obj.trainImg)!''}" />
                            <input type="hidden" name="trainImg" id="trainImg" value="${(obj.trainImg)!''}">
                            <input type="hidden" name="trainImgOld" id="trainImgOld" value="${(obj.trainImg)!''}">
                        </div>
					</div>
					<div class="form-group">
					<div class="form-group">
						<label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">培训视频 <span class="required">*</span>
                        </label>
                        <p><input type="file" name="fileName"/></p>
                        <input type="trainVideo" name="trainVideo" id="trainVideo" value="${(obj.trainVideo)!''}">
					</div>
					<div class="form-group">
						<label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">描述 <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                        	<input type="text" id="describe" name="describe" value="${(obj.describe)!''}" class="form-control col-md-7 col-xs-12">
                        </div>
					</div>
					
					<div class="ln_solid"></div>
					<div class="form-group">
						<div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3">
							<button type="button" class="btn btn-success" id="submit">保存</button>
							<button type="button" class="btn btn-primary" id="goBack">返回</button>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
</div>

<script type="text/javascript">
$(function() {

	$("#goBack").click(function() {
		$("#main_content").load('${base}/gx/sysTraining/list');	        
    });
    
         drEvent = $('#cardIcon_dropify').dropify();
     drEvent.on('dropify.afterClear', function(event, element) {
     	$("#trainImg").val("");
     });

     drEvent.on('dropify.errors', function(event, element) {
         console.log('Has Errors');
     });

	
	$("#submit").click(function() {
	
		var trainingTitle = $.trim($("#trainingTitle").val());

    	if(trainingTitle==""){
    		swal("请输入培训标题");
            return;
    	}
    	
    			drEvent = $("#cardIcon_dropify").dropify();
	    drEvent = drEvent.data('dropify');
	    if((drEvent.file.object !=null )){
	    	var infoIcon = drEvent.callBackBase64;
	    	infoIcon = infoIcon.substring(infoIcon.indexOf("base64")+7);
	    	$("#trainImg").val(infoIcon);
	    }else{
	    	if($("#trainImg").val()==""){
	    		swal("请上传图片");
	            return;
	    	}
	    }

    	//获取数据

        $("#postForm").ajaxSubmit(function(data) {
    	 	if (data.flag) {
    	 		swal(data.msg, "", "success");
				$("#main_content").load('${base}/gx/training/list');
    	 	} 
    	 	else {
    	 		swal(data.msg, "", "error");
    	 	}
    	});
	});
});
</script>